package com.banyuan.课堂练习.IO流;

import java.io.*;

/*
 * 将aaa和bbb合并到ccc中*/
public class Ex1 {
    public static void main(String[] args) {
        try (BufferedReader br1 = new BufferedReader(new FileReader("aaa.txt"));
             BufferedReader br2 = new BufferedReader(new FileReader("bbb.txt"));
             BufferedWriter bw = new BufferedWriter(new FileWriter("ccc.txt"))
        ) {
            String s;
            while((s = br1.readLine()) != null){
                bw.write(s);
                bw.newLine();
                bw.flush();
            }
            while((s = br2.readLine()) != null){
                bw.write(s);
                bw.newLine();
                bw.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
